﻿using CorpStore.Models;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml.Media.Imaging;

namespace CorpStore.ViewModels
{
    /// <summary>
    /// This class is used as a design mode only view model for easy XAML editing/viewing.
    /// It contains static, completely made-up (i.e. fake) data.
    /// </summary>
    class FakeViewModel : Common.BaseViewModel
    {
        public PackageInfoGroupList GroupList { get; set; }

        public string CorpStoreTitle
        {
            get { return GroupList.Settings["corpStoreTitle"] ?? ""; }
        }


        public PackageInfo CurrentApp { get; set; }
        public PackageInfoGroup CurrentGroup { get { return new PackageInfoGroup() { Name = "Test Group", Description = "My Descrip" }; } }

        public ScreenshotInfo SelectedScreenshot { get; set; }
        public string InstallRunText { get { return "Install & Run"; } }
        public string PinUnpinText { get { return "Pin to Start"; } }
        public bool GroupsExist { get { return true; } }

        public FakeViewModel()
        {
            defineGroupList();
            defineCurrentApp();
            defineFeatures();
            defineScreenshots();
            //defineCurrentGroup();

            OnPropertyChanged("SelectedScreenShot");
            OnPropertyChanged("CurrentApp");
            OnPropertyChanged("CurrentGroup");
            OnPropertyChanged("GroupList");
            OnPropertyChanged("GroupList.FeaturedApps");
        }

        private void defineScreenshots()
        {
            for (int i = 0; i < 4; i++)
                CurrentApp.Screenshots.Add(new ScreenshotInfo() { Filename = "ms-appx:///Assets/SunsetOnBoat.jpg", Description = "This is my awesome screenshot!" } );
            SelectedScreenshot = CurrentApp.Screenshots[0];
        }

        private void defineFeatures()
        {
            for (int i = 0; i < 10; i++)
            {
                CurrentApp.Features.Add("Feature " + i + " - very interesting indeed!  This is another very, very long feature to see if it will wrap!");
            }
        }

        private void defineCurrentApp()
        {
            CurrentApp = GroupList.FeaturedApps[0];
        }

        //private void defineCurrentGroup()
        //{
        //    CurrentGroup = GroupList.Groups[0];
        //}

        private void defineGroupList()
        {
            GroupList = new PackageInfoGroupList();

            GroupList.Settings.Add("corpDisplayName", "Contoso");
            GroupList.Settings.Add("corpPublisherDisplayName", "Microsoft Corporation");

            for (int i = 0; i < 10; i++)
            {
                PackageInfoGroup group = new PackageInfoGroup() { Name = "Group " + i, Description = "Description for Group " + i };
                for (int j = 0; j < 5; j++)
                {
                    PackageInfo newApp = new PackageInfo()
                    {
                        DisplayName = string.Format("App {0}-{1}", j, i),
                        Name = string.Format("App {0}-{1}", j, i),
                        LogoFn = "ms-appx:///Assets/StoreLogo.scale-100.png",
                        SplashScreenFn = "ms-appx:///Assets/StoreLogo.scale-100.png",
                        Screenshots = new List<ScreenshotInfo>() { new ScreenshotInfo("ms-appx:///Assets/SunsetOnBoat.jpg", "One and only screenshot") },
                        Description = string.Format("This is my very long description to see how it wraps in the little texblock for app {0}, group {1} sdjkldsaf jk jfdsal jasdlf jdsajf ldsa jfldsa jf jldsaj flkdsa jflkdsafd jlfjdsalf jdsaf jldsajl jfldsajfldsa jf jlkdsaflkdsa jfl jdsalf jl jdsafl jdsalf jdsalf jdsalkf jdsalkjslkda jfldsa jfll jdsafl jdsalf jdsalf jdsalf jlsa jfdsa jfldsa jf jdsalf jdsalf dsal fdsaj fk jdsalf dsaf jdsalfjs sla", j, i),
                        CreateDate = "1/1/1980",
                        Version="1.0.0.0",
                        PublisherDisplayName="Test Publishing",
                        GroupName = "Test Group",
                        InstalledLocation = "c:\\temp"
                    };
                    group.AddApplication(newApp);
                    if (j == 0)
                        GroupList.FeaturedApps.Add(newApp);
                }

                GroupList.Groups.Add(group);
            }
        }

    }
}
